const obj = {//整个对象叫iterable
  [Symbol.iterator]: function () {
    return {//该对象叫做iterator(指针对象)
      next: function () {
        return {//该对象叫做IterationResult
          value: 'zce',
          done: true
        }
      }
    }
  }
}
for (const item of obj) {
  console.log(item)
}

const obj1 = {
  arr: ['iterator1', 'iterator2', 'iterator2'],
  [Symbol.iterator]: function () {
    let index = 0;
    let that = this
    return {
      next: function () {
        return index < that.arr.length ? { value: that.arr[index++], done: false } : { value: undefined, done: true }
      }
    }
  }
}
for (const item of obj1) {
  console.log(item)
}